<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>W3Cschool教程(w3cschool.cn)</title>
</head>

<body>
    <!-- switch 语句 -->
    <div>
        <p>点击下面的按钮来显示今天是周几：</p>
        <button onclick="myFunction()">点击这里</button>
        <p id="demo"></p>
        <script>
            function myFunction() {
                var x;
                var d = new Date().getDay();
                switch (d) {
                    case 0: x = "今天是星期日";
                        break;
                    case 1: x = "今天是星期一";
                        break;
                    case 2: x = "今天是星期二";
                        break;
                    case 3: x = "今天是星期三";
                        break;
                    case 4: x = "今天是星期四";
                        break;
                    case 5: x = "今天是星期五";
                        break;
                    case 6: x = "今天是星期六";
                        break;
                }
                document.getElementById("demo").innerHTML = x;
            }
        </script>
    </div>
    <hr />
    <div>
        <h2>JavaScript switch</h2>
        <p id="deamo"></p>
        <script>
            var x = "0";

            switch (x) {
                case 0:
                    text = "Off";
                    break;
                case 1:
                    text = "On";
                    break;
                default:
                    text = "未找到值";
            }
            document.getElementById("deamo").innerHTML = text;
        </script>
    </div>
    <hr />
    <div>
        <h2>JavaScript switch</h2>
        <p id="deawdwadmo"></p>
        <script>
            var text;
            switch (new Date().getDay()) {
                default:
                    text = "期待周末";
                    break;
                case 6:
                    text = "今天是周六";
                    break;
                case 0:
                    text = "今天是周日";
            }
            document.getElementById("deawdwadmo").innerHTML = text;
        </script>
    </div>
    <hr />
    <div>
        <p>点击下面的按钮，会显示出基于今日日期的消息：</p>
        <button onclick="awdaw()">点击这里</button>
        <p id="awdawd"></p>
        <script>
        function awdaw()
        {
            var x;
            var d=new Date().getDay();
            switch (d)
            {
                  case 6:x="今天是星期六";
                break;
                  case 0:x="今天是星期日";
                break;
                  default:
                x="期待周末";
              }
            document.getElementById("awdawd").innerHTML=x;
        }
        </script>
    </div>
</body>

</html>